<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head runat="server">
    <title>微信绑定</title>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <meta content="initial-scale=1.0,user-scalable=no,maximum-scale=1,width=device-width,minimum-scale=1.0" name="viewport" />
    <meta content="yes" name="apple-mobile-web-app-capable" />
    <meta content="black" name="apple-mobile-web-app-status-bar-style" />
    <meta content="telephone=no" name="format-detection" />
    <link type="text/css" href="${pageContext.request.contextPath }/css/index.css" rel="stylesheet" />
    <script src="${pageContext.request.contextPath }/js/jquery-1.8.2.js"></script>
    <script src="${pageContext.request.contextPath }/js/jquery.tips.js"></script>
    <script src="${pageContext.request.contextPath }/js/message.js"></script>
</head>
<body>
    <form id="form1" runat="server">
        <div class="bangdingbox">
            <img src="${pageContext.request.contextPath }/images/iwcbanner.jpg">
        </div>
        <div class="bangdingcon">
            <ul>
                <li>
                    <input name="" id="txtCP" value="" runat="server" type="text" class="user" placeholder="请输入车牌号"></li>
                <li>
                    <input name="" id="txtPhone" value="" runat="server" type="text" class="iphone" placeholder="请输入手机号"></li>
            </ul>
            <input type="button" name="name" value="绑定" class="btn bangbtn" onclick="btncheck()"/>
        </div>

    </form>
</body>
</html>
<script type="text/javascript">
    function btncheck() {
    	
    	var mobile = $("#txtPhone").val();
    	var car_num = $("#txtCP").val();
    	
    	//表单参数校验
    	if(car_num == null || car_num == ""){
			$("#txtCP").tips({
				side:3,
	            msg:'车牌号不能为空',
	            bg:'#AE81FF',
	            time:2
	        });
			$("#txtCP").focus();
		   return false;
		}
    	
    	if(!(/^1[3|4|5|7|8]\d{9}$/.test(mobile))){
			$("#txtPhone").tips({
				side:3,
	            msg:'手机号格式错误',
	            bg:'#AE81FF',
	            time:2
	        });
			$("#txtPhone").focus();
		   return false;
		}
    	
    	//表单参数校验通过，提交表单
        $.ajax({
            type: "POST",
            url: "Business.ashx?para=CheckBind&phone=" + $("#txtPhone").val() + "&cp=" + $("#txtCP").val(),
            url: "${pageContext.request.contextPath }/driver/bind?mobile=" + mobile + "&car_num=" + car_num,
            async: true,
            timeout: 150000,
            dataType: "json",
            success: function (data) {
                $.MsgBox.Alert("油递员", data.message);
                if (0 == data.code) {
                    location = "${pageContext.request.contextPath }/index.jsp";
                }
            },
            error: function (XMLHttpRequest, textStatus, errorThrown) {
                $.MsgBox.Alert("油递员", "网络错误！");
            }
        });
    }
</script>
